﻿#region Using Statements
using System;
using System.Collections.Generic;
using System.Linq;
using System.Media;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;
using System.Diagnostics;
using System.IO;
#endregion using

namespace Turn_ament
{
    class Player
    {
        #region Attributes
        private int money;
        private string name;
        private Color color;
        private Base playerBase;
        private List<Unit> units;
        #endregion Attributes

        #region Constructor
        public Player(string playersName, Color color)
        {
            money = 0;
            name = playersName;
            this.color = color;
            units = new List<Unit>();
        }
        #endregion Constructor

        #region Properties
        public int Money
        {
            get { return money; }

            set { if (value >= 0) { money = value; } else { Console.WriteLine("You gave a player negative money."); } }
        }

        public string Name
        {
            get { return name; }

            set { if (value != null && value.Length > 0) { name = value; } else { Console.WriteLine("Give the player a real name!"); }}
        }

        public Color Color
        {
            get { return color; }

            set { color = value; }
        }

        public Base PlayerBase
        {
            get { return playerBase; }

            set { playerBase = value; }
        }

        public List<Unit> Units
        {
            get { return units; }

            set { units = value; }
        }
        #endregion Properties

        #region Methods
        public bool CheckIfCanAfford(int cost)
        {
            if (money - cost >= 0)
                return true;
            return false;
        }

        public void AddUnit(Unit addThis)
        {
            addThis.Player = this;
            addThis.Color = color;
            units.Add(addThis);
        }
        #endregion Methods

        #region Draw
        public void Draw()
        {
            units.ForEach(unit => unit.Draw());
        }
        #endregion Draw
    }
}
